From 70ca5a8a9c3b17c2c737cffced49e10cf74aee50 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 22 Jul 2004 06:22:04 +0000 Subject: [PATCH] Give compare more data to work with so qsort is stable. From John W. Temples, III --- gpsbabel/netstumbler.c | 22 ++++++++++++++++------ gpsbabel/reference/netstumbler.mps | Bin 4838 -> 4838 bytes 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gpsbabel/netstumbler.c b/gpsbabel/netstumbler.c index 699c63865..620cb1815 100644 --- a/gpsbabel/netstumbler.c +++ b/gpsbabel/netstumbler.c @@ -64,17 +64,17 @@ data_read(void) char ssid[2 + 32 + 2 + 1]; /* "( " + SSID + " )" + null */ char mac[2 + 17 + 2 + 1]; /* "( " + MAC + " )" + null */ char desc[sizeof ssid - 1 + 15 + 1]; /* room for channel/speed */ - double lat,lon; + double lat = 0, lon = 0; waypoint *wpt_tmp; int line_no = 0; int stealth_num = 0, whitespace_num = 0; - long flags; - int speed, channel; + long flags = 0; + int speed = 0, channel = 0; struct tm tm; for(; fgets(ibuf, sizeof(ibuf), file_in);) { char *field; - int field_num, len, i, stealth; + int field_num, len, i, stealth = 0; /* A sharp in column zero might be a comment. Or it might be * something useful, like the date. @@ -223,8 +223,18 @@ compare(const void *a, const void *b) return -1; else if (crc_a > crc_b) return 1; - else - return 0; + else { + /* CRCs are equal; we need to subsort on the description (which + * includes the MAC address) to guarantee the same ordering of + * the output for any qsort() implementation. this is strictly + * to make the testo script happy. + * */ + + waypoint *wpt_a = ((const htable_t *)a)->wpt; + waypoint *wpt_b = ((const htable_t *)b)->wpt; + + return strcmp(wpt_a->description, wpt_b->description); + } } /* netstumbler data will have a lot of duplicate shortnames if the SSID diff --git a/gpsbabel/reference/netstumbler.mps b/gpsbabel/reference/netstumbler.mps index 13e9dab0601ffa9d556e88e5710dac2d5dd18c97..c313182348d1eae58d4d4ff2e7046dd3296e030e 100644 GIT binary patch delta 123 zcmV->0EGYMCFUitJpz+c3mubM0%ns&2OYEB0$c=>+Yl?WV+Zg9lUEEKlW+^?lVlDZ zlXMJb0XLJu0vwa~4Cw(fli>}6liCa&lYtJ}4S)au09RLOa%F5~b90l>2_CbA4_5(` dFaiaWJ_iVszyck!1`$;O0ezEP4=9s{5@5yEDr*1$ delta 123 zcmaE+`b>3$Ez{(Oyt0#{n9?S{7LeV1mnnv2vH=t84o5j?V!oA_>lH6;nDY;NZdXPj)wuDzK